function getHTML( url ) {
    return new Promise(function(resolve, reject) {
        var xhr = new XMLHttpRequest;
        xhr.responseType = "document";
        xhr.open("GET", url, true);
        xhr.onload = function() {
            xhr.status === 200 ? resolve( xhr.response ) : reject( Error( xhr.status ) );
        }
        xhr.onerror = function() {
            reject( Error( xhr.status ) );
        }
        xhr.send( null );
    });
}
function openPage(url){
	getHTML( url ).then( function(html) {
        document.querySelector("html").innerHTML = html.querySelector("html").innerHTML;
    });
}

var LocString = String(window.document.location.href); 
function getQueryStr(str) { 
	var rs = new RegExp("(^|)" + str + "=([^&]*)(&|$)", "gi").exec(LocString), tmp; 
	if (tmp = rs) { 
	return tmp[2]; 
	} 
	// parameter cannot be found 
	return ""; 
} 

var httpUrl = "http://localhost:8080/hpe";

function FormatDate (strTime) {
    var date = new Date(strTime);
    var y = date.getFullYear(); 
	var m = date.getMonth()+1;//获取当前月份的日期 
	var d = date.getDate(); 
	return y+"-"+((m+"").length == 1?"0"+m:m)+"-"+((d+"").length == 1?"0"+d:d);
}

function getDateStr(AddDayCount) { 
	var dd = new Date(); 
	dd.setDate(dd.getDate()+AddDayCount);//获取AddDayCount天后的日期 
	var y = dd.getFullYear(); 
	var m = dd.getMonth()+1;//获取当前月份的日期 
	var d = dd.getDate(); 
	return y+"-"+((m+"").length == 1?"0"+m:m)+"-"+((d+"").length == 1?"0"+d:d); 
} 
function getURL(){  
    var curWwwPath = window.document.location.href;  
    //获取主机地址之后的目录，如： cis/website/meun.htm  
    var pathName = window.document.location.pathname;  
    var pos = curWwwPath.indexOf(pathName); //获取主机地址，如： http://localhost:8080  
    var localhostPaht = curWwwPath.substring(0, pos); //获取带"/"的项目名，如：/cis  
    var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);  
    var rootPath = localhostPaht + projectName;  
    return rootPath;  
      
}  